                    }});
                }});
            }
        }
     */
    /**
    }
 * 
 */
/**
} 
            // 安全警报
            // 按分组维度统计
     * 访客安全统计接口
     * 访客行为分析接口
     * 访客基础统计接口
 * 访客聚合查询控制器
                // 访客类型统计
                // 访客目的统计
     * 访客趋势分析接口
     * 访客详细统计接口
            // 访问路径分析
            // 访问频率分析
            // 访问时间分析
                // 高峰时段统计
            // 基础统计信息
            // 趋势数据
                // 停留时长统计
                afternoon.put("end", "16:00");
                afternoon.put("start", "14:00");
                afternoon.put("visitCount", 150);
            alert1.put("count", 3);
            alert1.put("severity", "medium");
            alert1.put("type", "unauthorized_access");
            alert2.put("count", 2);
            alert2.put("severity", "high");
            alert2.put("type", "suspicious_activity");
 * @author Wu.Liang
        } catch (Exception e) {
                duration.put("0-1hour", 500);
                duration.put("1-3hours", 300);
                duration.put("3-6hours", 150);
                duration.put("6+", 50);
            } else if ("duration".equals(statisticsType)) {
            } else if ("peak_hours".equals(statisticsType)) {
            } else if ("purpose".equals(statisticsType)) {
                evening.put("end", "20:00");
                evening.put("start", "18:00");
                evening.put("visitCount", 180);
    @GetMapping("/aggregate")
    @GetMapping("/behavior")
    @GetMapping("/detail")
    @GetMapping("/security")
    @GetMapping("/trend")
            if ("community".equals(groupBy)) {
            if (communityIdList.isEmpty()) {
            if ("visit_type".equals(statisticsType)) {
import com.smart.community.commons.result.Result;
import com.smart.community.commons.utils.BatchQueryUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
            List<Long> buildingIdList = buildingIds != null ? BatchQueryUtils.parseIds(buildingIds) : null;
            List<Long> communityIdList = BatchQueryUtils.parseIds(communityIds);
            log.error("获取访客安全统计失败", e);
            log.error("获取访客行为分析失败", e);
            log.error("获取访客基础统计失败", e);
            log.error("获取访客趋势分析失败", e);
            log.error("获取访客详细统计失败", e);
                Map<String, Integer> duration = new HashMap<>();
                Map<String, Integer> purpose = new HashMap<>();
            Map<String, Integer> visitFrequency = new HashMap<>();
                Map<String, Integer> visitType = new HashMap<>();
                Map<String, Object> afternoon = new HashMap<>();
            Map<String, Object> alert1 = new HashMap<>();
            Map<String, Object> alert2 = new HashMap<>();
                Map<String, Object> evening = new HashMap<>();
                Map<String, Object> morning = new HashMap<>();
                Map<String, Object> peakHours = new HashMap<>();
            Map<String, Object> result = new HashMap<>();
            Map<String, Object>[] securityAlerts = new Map[2];
            Map<String, Object> statisticsByGroup = new HashMap<>();
            Map<String, Object> trendData = new HashMap<>();
            Map<String, Object> visitPathAnalysis = new HashMap<>();
            Map<String, Object> visitTimeAnalysis = new HashMap<>();
                morning.put("end", "10:00");
                morning.put("start", "08:00");
                morning.put("visitCount", 200);
    @Operation(summary = "访客安全统计", description = "获取访客安全统计信息")
    @Operation(summary = "访客行为分析", description = "获取访客行为分析数据")
    @Operation(summary = "访客基础统计", description = "获取访客基础统计信息")
    @Operation(summary = "访客趋势分析", description = "获取访客趋势分析数据")
    @Operation(summary = "访客详细统计", description = "获取访客详细统计信息")
package com.smart.community.visitor.controller;
            @Parameter(description = "分组维度：community/building/visit_type") @RequestParam(required = false) String groupBy) {
            @Parameter(description = "楼栋ID集合，逗号分隔") @RequestParam(required = false) String buildingIds,
            @Parameter(description = "社区ID集合，逗号分隔") @RequestParam String communityIds,
            @Parameter(description = "时间范围：today/week/month/year") @RequestParam(required = false) String timeRange) {
            @Parameter(description = "时间范围：today/week/month/year") @RequestParam(required = false) String timeRange,
            @Parameter(description = "时间范围：week/month/quarter/year") @RequestParam String timeRange) {
            @Parameter(description = "时间范围：week/month/quarter/year") @RequestParam String timeRange,
            @Parameter(description = "统计类型：visit_type/duration/peak_hours/purpose") @RequestParam String statisticsType) {
            @Parameter(description = "指标：visit_count/avg_duration/peak_hours") @RequestParam String metric) {
                peakHours.put("afternoon", afternoon);
                peakHours.put("evening", evening);
                peakHours.put("morning", morning);
public class VisitorStatisticsController {
    public Result<Map<String, Object>> getVisitorAggregateStatistics(
    public Result<Map<String, Object>> getVisitorBehaviorAnalysis(
    public Result<Map<String, Object>> getVisitorDetailStatistics(
    public Result<Map<String, Object>> getVisitorSecurityStatistics(
    public Result<Map<String, Object>> getVisitorTrendAnalysis(
                purpose.put("businessMeeting", 200);
                purpose.put("delivery", 200);
                purpose.put("familyVisit", 400);
                purpose.put("maintenance", 100);
                purpose.put("other", 100);
                    put("1", new HashMap<String, Object>() {{
                        put("completedVisits", 475);
                        put("currentVisits", 25);
                        put("totalVisits", 500);
@RequestMapping("/visitor/statistics")
@RestController
            result.put("approvalRate", 95.0);
            result.put("approvedVisits", 950);
            result.put("averageDuration", 2.5); // 平均停留时长
            result.put("changeRate", 10.0);
            result.put("completedVisits", 950); // 已完成访客数
            result.put("currentVisits", 50); // 当前访客数
                result.put("duration", duration);
            result.put("incidentRate", 0.5);
                result.put("peakHours", peakHours);
            result.put("pendingVisits", 20);
                result.put("purpose", purpose);
            result.put("rejectedVisits", 30);
            result.put("securityAlerts", securityAlerts);
            result.put("securityIncidents", 5);
            result.put("statisticsByGroup", statisticsByGroup);
            result.put("timePoints", new String[]{"2024-01-01", "2024-01-02", "2024-01-03"});
            result.put("totalVisits", 1000);
            result.put("totalVisits", 1000); // 总访客数
            result.put("trendData", trendData);
            result.put("trend", "increasing");
            result.put("values", new Integer[]{100, 120, 110});
            result.put("visitFrequency", visitFrequency);
            result.put("visitPathAnalysis", visitPathAnalysis);
            result.put("visitTimeAnalysis", visitTimeAnalysis);
                result.put("visitType", visitType);
                return Result.fail("参数communityIds不能为空");
            return Result.fail("查询失败：" + e.getMessage());
            return Result.success(result);
    @SaCheckPermission("visitor:menu")
            securityAlerts[0] = alert1;
            securityAlerts[1] = alert2;
 * @since 2024-12-21
@Slf4j
                statisticsByGroup.put("community", new HashMap<String, Object>() {{
@Tag(name = "访客聚合查询", description = "访客统计信息查询相关接口")
            trendData.put("dates", new String[]{"2024-01-01", "2024-01-02"});
            trendData.put("visitCounts", new Integer[]{100, 120});
        try {
            visitFrequency.put("firstTime", 300);
            visitFrequency.put("frequent", 100);
            visitFrequency.put("occasional", 400);
            visitFrequency.put("regular", 200);
            visitPathAnalysis.put("mainEntrance", 800);
            visitPathAnalysis.put("parkingEntrance", 50);
            visitPathAnalysis.put("sideEntrance", 150);
            visitTimeAnalysis.put("holidayVisits", 100);
            visitTimeAnalysis.put("weekdayVisits", 600);
            visitTimeAnalysis.put("weekendVisits", 400);
                visitType.put("business", 300);
                visitType.put("delivery", 200);
                visitType.put("family", 400);
                visitType.put("maintenance", 100);
